package com.mao.model.product;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.struts2.json.annotations.JSON;

import com.mao.model.BaseModel;
import com.mao.model.warehouse.WareHouse;

@Entity
@Table(name = "MAO_PRODUCT")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
public class Product extends BaseModel {

	private static final long serialVersionUID = 2362668455693099126L;

	private long id;

	private String name;

	private String proNo; // 编号

	private String spec; // 规格

	private BigDecimal retailPrice = new BigDecimal(0); // 零售价

	private BigDecimal lowestPrice = new BigDecimal(0); // 最低售价

	private String note; // 备注

	private ProductClass proClass;

	private Date createTime;

	private Integer initStock; // 当前库存

	private WareHouse initWareHouse; // 初始库存的仓库

	@Id
	@GeneratedValue
	@Column(name = "ID")
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@Column(name = "NAME", nullable = false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "PRONO")
	public String getProNo() {
		return proNo;
	}

	public void setProNo(String proNo) {
		this.proNo = proNo;
	}

	@Column(name = "SPEC")
	public String getSpec() {
		return spec;
	}

	public void setSpec(String spec) {
		this.spec = spec;
	}

	@Column(name = "NOTE", columnDefinition = "TEXT")
	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	@ManyToOne(optional = true, fetch = FetchType.LAZY)
	@JoinColumn(name = "PRODUCTCLASS", nullable = false, columnDefinition = "int default 0")
	@JSON(serialize = false)
	public ProductClass getProClass() {
		return proClass;
	}

	public void setProClass(ProductClass proClass) {
		this.proClass = proClass;
	}

	@Column(name = "RETAILPRICE", scale = 2, nullable = false)
	public BigDecimal getRetailPrice() {
		return retailPrice;
	}

	public void setRetailPrice(BigDecimal retailPrice) {
		this.retailPrice = retailPrice;
	}

	@Column(name = "LOWESTPRICE", scale = 2, nullable = false)
	public BigDecimal getLowestPrice() {
		return lowestPrice;
	}

	public void setLowestPrice(BigDecimal lowestPrice) {
		this.lowestPrice = lowestPrice;
	}

	@Column(name = "CREATETIME")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "INITSTOCK", columnDefinition = "int default 0")
	public Integer getInitStock() {
		return initStock;
	}

	public void setInitStock(Integer initStock) {
		this.initStock = initStock;
	}

	@ManyToOne(optional = true, fetch = FetchType.LAZY)
	@JoinColumn(name = "INITWAREHOUSE", nullable = true)
	@JSON(serialize = false)
	public WareHouse getInitWareHouse() {
		return initWareHouse;
	}

	public void setInitWareHouse(WareHouse initWareHouse) {
		this.initWareHouse = initWareHouse;
	}

}
